﻿using Microsoft.EntityFrameworkCore;

namespace Discount.GRPC.Data
{
    //注意该扩展还是需要add-migration命令来生成迁移文件
    //它做的只是比较。更新数据库
    public static class MigrationExtension
    {
        public static void UseMigraion(this IApplicationBuilder app)
        {
           using var scope = app.ApplicationServices.CreateScope();
           using var context = scope.ServiceProvider.GetRequiredService<DiscountDbContext>();
           context.Database.MigrateAsync();
        }
    }
}
